home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-13 / mewin10s.zip / ESTRUCT.H < prev    next >
C/C++ Source or Header  |  1992-03-14  |  32KB  |  1,011 lines

  1. /*    ESTRUCT:    Structure and preprocesser defined for
  2.             MicroEMACS 3.11
  3.  
  4.             written by Daniel Lawrence
  5.             based on code by Dave G. Conroy,
  6.                 Steve Wilhite and George Jones
  7. */
  8.  
  9. #ifdef    LATTICE
  10. #undef    LATTICE      /* don't use their definitions...use ours     */
  11. #endif
  12. #ifdef    MSDOS
  13. #undef    MSDOS
  14. #endif
  15. #ifdef    AMIGA
  16. #undef    AMIGA
  17. #endif
  18. #ifdef    EGA
  19. #undef    EGA
  20. #endif
  21. #ifdef    CTRLZ
  22. #undef    CTRLZ
  23. #endif
  24.  
  25. /*    Program Identification.....
  26.  
  27.     PROGNAME should always be MicroEMACS for a distribution
  28.     unmodified version. People using MicroEMACS as a shell
  29.     for other products should change this to reflect their
  30.     product. Macros can query this via the $progname variable
  31. */
  32.  
  33. #define PROGNAME    "MicroEMACS"
  34. #define    VERSION        "3.11c"
  35.  
  36. /*    Machine/OS definitions            */
  37. /*    [Set one of these!!]            */
  38.  
  39. #define AMIGA    0            /* AmigaDOS            */
  40. #define AOSVS    0            /* Data General AOS/VS        */
  41. #define AVIION    0            /* Data General AViiON        */
  42. #define BSD    0            /* UNIX BSD 4.2 and ULTRIX    */
  43. #define FINDER    0            /* Macintosh OS         */
  44. #define HPUX    0            /* HPUX HP 9000 minicomputer    */
  45. #define MPE    0            /* HP MPE/XL            */
  46. #define MSDOS    1            /* MS-DOS            */
  47. #define OS2    0            /* Microsoft or IBM OS/2    */
  48. #define SMOS    0            /* Supermax UNIX System V    */
  49. #define SUN    0            /* SUN v4.0            */
  50. #define TOS    0            /* ST520, TOS            */
  51. #define USG    0            /* UNIX system V        */
  52. #define V7    0            /* V7 UNIX or Coherent or BSD4.2*/ 
  53. #define VMS    0            /* VAX/VMS            */
  54. #define WMCS    0            /* Wicat's MCS            */
  55. #define XENIX    0            /* IBM-PC SCO XENIX        */
  56.  
  57. /*    Compiler definitions            */
  58. /*    [Set one of these!!]            */
  59. #define    ALCYON    0    /* ALCYON Atari ST compiler */ 
  60. #define    DGC    0    /* Data General AOS/VS C... */
  61. #define AZTEC    0    /* Aztec C 3.20e */
  62. #define DTL    0    /* DataLight C v3.12 */
  63. #define GCC    0    /* the GNU C compiler */
  64. #define LATTICE 0    /* Lattice 2.14 through 3.0 compilers */
  65. #define MSC    0    /* MicroSoft C compile version 3 & 4 & 5.1 & 6 */
  66. #define MWC    0    /* Mark Williams C */
  67. #define TURBO    1    /* Turbo C/MSDOS */
  68. #define UNIX    0    /* a standard UNIX compiler (cc) */
  69. #define    ZTC    0    /* Zortech C/C++ 1.02 thru 2.10 under MSDOS */
  70.  
  71. /*      Machine stack growth direction.                     */
  72. /*  [Set this to 1 if your machine stack grows UP!!!]       */
  73. /*      data general mv/eclipse series stack grows up.      */
  74. /*      dec vax series stack grows down... got it???        */
  75.  
  76. #define STACK_GROWS_UP  0
  77.  
  78. /*    Debugging options    */
  79. #define    RAMSIZE    0    /* dynamic RAM memory usage tracking */
  80. #define    RAMSHOW    0    /* auto dynamic RAM reporting */
  81. #define    RAMTRCK    0    /* send debug info to MALLOC.DAT */
  82.  
  83. /*   Special keyboard/network definitions         */
  84.  
  85. #define ATKBD    0        /* AT-style keyboard with F11, F12 & grey keys */
  86. #define WANGPC    0        /* WangPC - mostly escape sequences    */
  87. #define VT100    0        /* Handle VT100 style keypad - NOT VMS.    */
  88. #define    NOVELL    0        /* IBMPC Novell NetWare flag! */
  89. #define KEYPAD    0        /* VMS - turn on and off application    */
  90.                 /* keypad automatically */
  91. #define XONDATA    0        /* VMS - set to force /NOTTSYNC/NOHOSTSY */
  92. #define    RMSIO    0        /* VMS - skip the rotten C runtime and    */
  93.                 /* use RMS directly            */
  94. #define OPTMEM    0        /* VMS 5.0 and up - use a less standard */
  95.                 /* but more efficient memory allocator    */
  96.  
  97. /*    Terminal Output definitions        */
  98. /*    [Set one of these!!]            */
  99.  
  100. #define ANSI    0            /* ANSI escape sequences    */
  101. #define DASHER    0            /* DG Dasher 2xx/4xx crts    */
  102. #define DG10    0            /* Data General system/10    */
  103. #define FMR    0            /* Fujitsu FMR series driver    */
  104. #define HP110    0            /* HP110 screen driver        */
  105. #define HP150    0            /* HP150 screen driver        */
  106. #define    I55    0            /* IBM PS55 DOS J4.0/V        */
  107. #define IBMPC    0            /* IBM-PC CGA/MONO/EGA/VGA drvr    */
  108. #define MAC    0            /* Macintosh            */
  109. #define NEC    0            /* NEC-9801VM driver        */
  110. #define OS2NPM    0            /* OS/2 non-Presentation Mgr.    */
  111. #define RAINBOW 0            /* Use Rainbow fast video.    */
  112. #define SMG    0            /* SMG library on VMS        */
  113. #define ST52    0            /* Atari 520/1040ST screen    */
  114. #define TERMCAP 0            /* Use TERMCAP            */
  115. #define TIPC    0            /* TI Profesional PC driver    */
  116. #define VT52    0            /* VT52 terminal (Zenith).    */
  117. #define Z309    0            /* Zenith 100 PC family    driver    */
  118.  
  119. /*    Windowing system style (pick one)                */
  120.  
  121. #define    WINDOW_TEXT    0        /* Text mode.... simple updates    */
  122. #define    WINDOW_XVT    0        /* using XVT/any platform    */
  123. #define    WINDOW_MSWIN    1        /* MicroSoft Windows        */
  124. #define    WINDOW_X    0        /* X/Unix            */
  125.  
  126. /*    Language text options    (pick one)                */
  127.  
  128. #define ENGLISH 1
  129. #define    FRENCH    0
  130. #define    SPANISH    0
  131. #define    GERMAN    0
  132. #define    DUTCH    0
  133. #define PLATIN    0
  134. #define    JAPAN    0
  135. #define    LATIN    0
  136.  
  137. /*    Configuration options    */
  138.  
  139. #define    TYPEAH    0    /* type ahead causes update to be skipped    */
  140. #define DEBUGM    1    /* $debug triggers macro debugging        */
  141. #define    LOGFLG    0    /* send all executed commands to EMACS.LOG    */
  142. #define    VISMAC    0    /* update display during keyboard macros    */
  143. #define    CTRLZ    0    /* add a ^Z at end of files under MSDOS only    */
  144. #define    CLEAN    0    /* de-alloc memory on exit            */
  145. #define    CALLED    0    /* is emacs a called subroutine? or stand alone */
  146.  
  147. #define REVSTA    1    /* Status line appears in reverse video     */
  148. #define    COLOR    1    /* color commands and windows            */
  149.  
  150. #define FILOCK    0    /* file locking under unix BSD 4.2        */
  151. #define    ISRCH    1    /* Incremental searches like ITS EMACS        */
  152. #define    FLABEL    0    /* function key label code [HP150]        */
  153. #define    CRYPT    1    /* file encryption enabled?            */
  154. #define MAGIC    1    /* include regular expression matching?        */
  155. #define MOUSE    1     /* Include routines for mouse actions        */
  156. #define    NOISY    1    /* Use a fancy BELL if it exists        */
  157. #define CTAGS    0    /* include vi-like tagging?            */
  158. #define    SPEECH    0    /* spoken EMACS, for the sight impared [not ready] */
  159. #define    VARARG    1    /* use varargs.h for mlwrite()            */
  160.  
  161. /*    Character set options        */
  162. /*    [Set one of these!!]        */
  163. #define ASCII    1    /* always using ASCII char sequences for now    */
  164. #define EBCDIC    0    /* later IBM mainfraim versions will use EBCDIC    */
  165.  
  166. /* handle constant and voids properly */
  167.  
  168. #if    VMS
  169. #define    CONST    readonly
  170. #define    VOID    void
  171. #define NOSHARE noshare
  172. #else
  173. #if    AOSVS
  174. #define CONST $shared $align(1)     /* fake a  const */
  175. #define    VOID
  176. #define NOSHARE $low32k $align(1)   /* attempt to optimize read/write vars. */
  177. #else
  178. #if    __STDC__ || MSC || TURBO || DTL || GCC || ZTC
  179. #define    CONST    /* const (produces spurious warnings under BC3.0) */
  180. #define    VOID    void
  181. #define    NOSHARE
  182. #else
  183. #define    CONST
  184. #define    VOID
  185. #define NOSHARE
  186. #endif
  187. #endif
  188. #endif
  189.  
  190. /*    System dependant library redefinitions, structures and includes */
  191.  
  192. /*    the following define allows me to initialize unions...
  193.     otherwise we make them structures (like the keybinding table)  */
  194.  
  195. /*    multibyte character support?    */
  196.  
  197. #if    NEC || FMR || I55
  198. #define    DBCS    1    /* double byte character sets enabled */
  199. #define    INSDEL    1    /* use insert/delete line display optimizations */
  200.  
  201. /* define DBCS prefix bytes */
  202. #define    is2char(ch) (((ch&0xff) >= 0x81 && (ch&0xff) <= 0x9f) || ((ch&0xff) >=0xe0 && (ch&0xff) <= 0xfc))
  203.  
  204. #else
  205. #define    DBCS    0
  206. #define    INSDEL    0
  207. #endif
  208.  
  209. /*    Prototypes in use?    */
  210.  
  211. #if    MSC || TURBO || DTL || VMS || GCC || ZTC
  212. #define    PROTO    1
  213. #else
  214. #define    PROTO    0
  215. #endif
  216.  
  217.  
  218. /* Gnu can't for some reason...*/
  219. #if    (__STDC__ && (GCC == 0)) || MSC || TURBO || DTL || VMS || GCC || ZTC
  220. #define    ETYPE    union
  221. #else
  222. #define    ETYPE    struct
  223. #endif
  224.  
  225. #if MSDOS & (TURBO | MSC | TIPC)
  226. #define    NEAR
  227. #define    DNEAR
  228. #define    PASCAL pascal
  229. #define    CDECL cdecl
  230. #else
  231. #if MSDOS & ZTC
  232. #define    NEAR
  233. #define    DNEAR
  234. #define    PASCAL _pascal
  235. #define    CDECL _cdecl
  236. #else
  237. #define NEAR
  238. #define    DNEAR
  239. #define    PASCAL
  240. #define    CDECL
  241. #endif
  242. #endif
  243.  
  244. #if     WINDOW_MSWIN
  245. #undef  TYPEAH
  246. #define TYPEAH  0   /* typeahead is handled at the term driver level */
  247. #undef  CALLED
  248. #define CALLED  1   /* under MS Windows, "main" resides in the sys driver */
  249. #if     TURBO       /* actually Borland C++ 2.0 */
  250. #define EXPORT  _export
  251. #else
  252. #define EXPORT      /* other compilers (MS-C for instance) would need a
  253.                .DEF file to list the exported functions */
  254. #endif
  255. #endif
  256.  
  257. #if    TURBO
  258. #include      <dos.h>
  259. #include      <mem.h>
  260. #undef peek
  261. #undef poke
  262. #define       peek(a,b,c,d)   movedata(a,b,FP_SEG(c),FP_OFF(c),d)
  263. #define       poke(a,b,c,d)   movedata(FP_SEG(c),FP_OFF(c),a,b,d)
  264. #endif
  265.  
  266. #if    LATTICE & MSDOS
  267. /* you may have to remove this one definition with LATTICE version
  268.    3.2 and above                          */
  269. #define    unsigned
  270. #endif
  271.  
  272. #if    AZTEC
  273. #undef    putc
  274. #undef    getc
  275. #if    MSDOS
  276. #define    getc    a1getc
  277. #define    int86    sysint
  278. #define    intdos(a, b)    sysint(33, a, b)
  279. #define    inp    inportb
  280. #define    outp    outportb
  281. #else
  282. #define getc    agetc
  283. #endif
  284. #define putc    aputc
  285.  
  286. struct XREG {
  287.     unsigned ax,bx,cx,dx,si,di,ds,es;
  288. };
  289.  
  290. struct HREG {
  291.     char al,ah,bl,bh,cl,ch,dl,dh,d1,d2,e1,e2;
  292. };
  293.  
  294. union REGS {
  295.     struct XREG x;
  296.     struct HREG h;
  297. };
  298.  
  299. struct SREGS {
  300.     unsigned cs, ss, ds, es;
  301. };
  302. #endif
  303.  
  304. #if    MSDOS & DTL
  305. #include    <dos.h>
  306. #endif
  307.  
  308. #if    MSDOS & MWC
  309. #include    <dos.h>
  310. #define    int86(a, b, c)    intcall(b, c, a)
  311. #define    intdos(a, b)    intcall(a, b, DOSINT)
  312. #define    inp(a)        in(a)
  313. #define    outp(a, b)    out(a, b)
  314. #define    movmem(a, b, c)    memcpy(b, a, c)
  315.  
  316. struct XREG {
  317.     unsigned int ax,bx,cx,dx,si,di,ds,es,flags;
  318. };
  319.  
  320. struct HREG {
  321.     char al,ah,bl,bh,cl,ch,dl,dh;
  322.     unsigned int ds,es,flags;
  323. };
  324.  
  325. union REGS {
  326.     struct XREG x;
  327.     struct HREG h;
  328. };
  329. #endif
  330.  
  331. #if    MSDOS & MSC
  332. #include    <dos.h>
  333. #include    <memory.h>
  334. #define    peek(a,b,c,d)    movedata(a,b,FP_SEG(c),FP_OFF(c),d)
  335. #define    poke(a,b,c,d)    movedata(FP_SEG(c),FP_OFF(c),a,b,d)
  336. #define    movmem(a, b, c)        memcpy(b, a, c)
  337. #endif
  338.  
  339. #if    MSDOS & LATTICE
  340. #undef    CPM
  341. #undef    LATTICE
  342. #include    <dos.h>
  343. #undef    CPM
  344. #endif
  345.  
  346. /* System V doesn't name this the same as others */
  347. #if    USG | SUN | (OS2 & MSC)
  348. #define    movmem(a, b, c)        memcpy(b, a, c)
  349. #endif
  350.  
  351. /* this keeps VMS happy */
  352. #if    VMS
  353. #define    getname xgetname
  354. #define    unlink(a)    delete(a)
  355. #endif
  356.  
  357. /* some options for AOS/VS */
  358. #if     AOSVS
  359. #define ORMDNI  1
  360. #endif
  361.  
  362. /*    define some ability flags */
  363.  
  364. #if    IBMPC | Z309 | FMR | TIPC
  365. #define    MEMMAP    1
  366. #else
  367. #define MEMMAP    0
  368. #endif
  369.  
  370. #if    MSDOS | OS2 | V7 | USG | SMOS | HPUX | BSD | (TOS & MWC) | WMCS | SUN | MPE
  371. #define    ENVFUNC    1
  372. #else
  373. #define ENVFUNC 0
  374. #endif
  375.  
  376. #if    MPE
  377. #define DIRSEPSTR    "."
  378. #define DIRSEPCHAR    '.'
  379. #else
  380. #if    TOS || MSDOS || OS2
  381. #define    DIRSEPSTR    "\\"
  382. #define    DIRSEPCHAR    '\\'
  383. #else
  384. #define DIRSEPSTR    "/"
  385. #define    DIRSEPCHAR    '/'
  386. #endif
  387. #endif
  388.  
  389. #define    DRIVESEPCHAR    ':'
  390.  
  391. #if    VARARG
  392. #if    USG || BSD || SUN || XENIX || HPUX || AVIION || MPE
  393. #define    VARG    1
  394. #define    SARG    0
  395. #include    <varargs.h>
  396. #else
  397. #define    VARG    0
  398. #define    SARG    1
  399. #include    <stdarg.h>
  400. #endif
  401. #endif
  402.  
  403. #if ZTC
  404. #include     <dos.h>
  405. #define      movmem(a, b, c) memcpy(b, a, c)
  406. #endif
  407.  
  408. /*    Emacs global flag bit definitions (for gflags)    */
  409.  
  410. #define GFREAD    1    /* read first file in at startup */
  411. #define GFSDRAW    2    /* suppress a screen redraw */
  412.  
  413. /*    internal constants    */
  414.  
  415. #define NBINDS    300            /* max # of bound keys        */
  416. #if    AOSVS | VMS
  417. #define    NFILEN    256
  418. #else
  419. #define NFILEN    80            /* # of bytes, file name    */
  420. #endif
  421. #define NBUFN    32            /* # of bytes, buffer name    */
  422. #define NLINE    256            /* # of bytes, input line    */
  423. #define    NSTRING    128            /* # of bytes, string buffers    */
  424. #define NKBDM    256            /* # of strokes, keyboard macro */
  425. #define NPAT    128            /* # of bytes, pattern        */
  426. #define HUGE    1000            /* Huge number            */
  427. #define    NLOCKS    100            /* max # of file locks active    */
  428. #define    NCOLORS    16            /* number of supported colors    */
  429. #define    KBLOCK    250            /* sizeof kill buffer chunks    */
  430. #define    NRING    16            /* # of buffers in kill ring    */
  431. #define    NBLOCK    16            /* line block chunk size    */
  432. #define    NVSIZE    10            /* max #chars in a var name    */
  433. #define NMARKS    10            /* number of marks        */
  434.  
  435. #define CTRL    0x0100        /* Control flag, or'ed in        */
  436. #define META    0x0200        /* Meta flag, or'ed in            */
  437. #define CTLX    0x0400        /* ^X flag, or'ed in            */
  438. #define SPEC    0x0800        /* special key (function keys)        */
  439. #define MOUS    0x1000        /* alternative input device (mouse)    */
  440. #define    SHFT    0x2000        /* shifted (for function keys)        */
  441. #define    ALTD    0x4000        /* ALT key...                */
  442. #define MENU    MOUS+SPEC       /* menu selection (WINDOW_MSWIN)        */
  443.  
  444. #define    BINDNUL    0        /* not bount to anything        */
  445. #define    BINDFNC    1        /* key bound to a function        */
  446. #define    BINDBUF    2        /* key bound to a buffer        */
  447.  
  448. #define    FORWARD        0    /* doing things forward            */
  449. #define    BACKWARD    -1    /* doing things in reverse        */
  450.  
  451. #ifdef    FALSE
  452. #undef    FALSE
  453. #endif
  454. #ifdef    TRUE
  455. #undef    TRUE
  456. #endif
  457.  
  458. #define FALSE    0            /* False, no, bad, etc.     */
  459. #define TRUE    1            /* True, yes, good, etc.    */
  460. #define ABORT    2            /* Death, ^G, abort, etc.    */
  461. #define    FAILED    3            /* not-quite fatal false return    */
  462.  
  463. #define STOP    0            /* keyboard macro not in use    */
  464. #define    PLAY    1            /*          playing    */
  465. #define    RECORD    2            /*          recording    */
  466.  
  467. /*    Competion types        */
  468.  
  469. #define    CMP_BUFFER    0
  470. #define    CMP_COMMAND    1
  471. #define    CMP_FILENAME    2
  472.  
  473. /*    Directive definitions    */
  474.  
  475. #define DIF        0
  476. #define DELSE        1
  477. #define DENDIF        2
  478. #define DGOTO        3
  479. #define DRETURN        4
  480. #define DENDM        5
  481. #define DWHILE        6
  482. #define    DENDWHILE    7
  483. #define    DBREAK        8
  484. #define DFORCE        9
  485.  
  486. #define NUMDIRS     10
  487.  
  488. /*
  489.  * PTBEG, PTEND, FORWARD, and REVERSE are all toggle-able values for
  490.  * the scan routines.
  491.  */
  492. #define PTBEG    0    /* Leave the point at the beginning on search    */
  493. #define    PTEND    1    /* Leave the point at the end on search        */
  494. #define    FORWARD    0            /* forward direction        */
  495. #define REVERSE    1            /* backwards direction        */
  496.  
  497. #define FIOSUC    0            /* File I/O, success.        */
  498. #define FIOFNF    1            /* File I/O, file not found.    */
  499. #define FIOEOF    2            /* File I/O, end of file.    */
  500. #define FIOERR    3            /* File I/O, error.        */
  501. #define    FIOMEM    4            /* File I/O, out of memory    */
  502. #define    FIOFUN    5            /* File I/O, eod of file/bad line*/
  503. #define    FIODEL    6            /* Can't delete/rename file    */
  504.  
  505. #if     WINDOW_MSWIN
  506. /* values for the fbusy flag */
  507. #define FREADING 1                      /* file read in progress */
  508. #define FWRITING 2                      /* file write in progress */
  509. /* if no file activity, the value FALSE is used */
  510. #endif
  511.  
  512. #define CFCPCN    0x0001            /* Last command was C-P, C-N    */
  513. #define CFKILL    0x0002            /* Last command was a kill    */
  514. #define    CFSRCH    0x0004            /* last command was a search    */
  515. #define CFYANK    0x0008            /* last command was a yank    */
  516.  
  517. #define    SRNORM    0            /* end past, begin front    */
  518. #define    SRBEGIN    1            /* always at front        */
  519. #define    SREND    2            /* always one past end        */
  520.  
  521. #define BELL    0x07            /* a bell character        */
  522. #define    TAB    0x09            /* a tab character        */
  523.  
  524. #if    V7 | USG | SMOS | HPUX | BSD | SUN | XENIX | AVIION
  525. #define    PATHCHR    ':'
  526. #else
  527. #if    WMCS || MPE
  528. #define    PATHCHR ','
  529. #else
  530. #define PATHCHR ';'
  531. #endif
  532. #endif
  533.  
  534. #define INTWIDTH    sizeof(int) * 3
  535.  
  536. /*    Macro argument token types                    */
  537.  
  538. #define TKNUL    0            /* end-of-string        */
  539. #define    TKARG    1            /* interactive argument        */
  540. #define    TKBUF    2            /* buffer argument        */
  541. #define    TKVAR    3            /* user variables        */
  542. #define    TKENV    4            /* environment variables    */
  543. #define    TKFUN    5            /* function....            */
  544. #define    TKDIR    6            /* directive            */
  545. #define    TKLBL    7            /* line label            */
  546. #define    TKLIT    8            /* numeric literal        */
  547. #define    TKSTR    9            /* quoted string literal    */
  548. #define    TKCMD    10            /* command name            */
  549.  
  550. /*    Internal defined functions                    */
  551.  
  552. #define nextab(a)    (a - (a % tabsize)) + tabsize
  553.  
  554. /* DIFCASE represents the integer difference between upper
  555.    and lower case letters.  It is an xor-able value, which is
  556.    fortunate, since the relative positions of upper to lower
  557.    case letters is the opposite of ascii in ebcdic.
  558. */
  559.  
  560. #ifdef    islower
  561. #undef    islower
  562. #endif
  563. #ifdef    isupper
  564. #undef    isupper
  565. #endif
  566.  
  567. #if    ASCII
  568. #define    DIFCASE     0x20
  569. #else
  570. #define DIFCASE        0x40
  571. #endif
  572.  
  573. /* and keep the new sun compiler happy.... */
  574. #if    SUN
  575. #undef    isupper
  576. #undef    islower
  577. #define    isupper(a)    isucase(a)
  578. #define    islower(a)    islcase(a)
  579. #endif
  580.  
  581. /*    Dynamic RAM tracking and reporting redefinitions    */
  582.  
  583. #if    RAMSIZE
  584. #define    malloc    allocate
  585. #define    free    release
  586. #else
  587. #if    VMS & OPTMEM
  588. #define malloc     VAXC$MALLOC_OPT
  589. #define free    VAXC$FREE_OPT
  590. #define calloc    VAXC$CALLOC_OPT
  591. #define realloc VAXC$REALLOC_OPT
  592. #define cfree   VAXC$CFREE_OPT
  593. #endif
  594. #endif
  595.  
  596. /* under MS Windows, we use dialog boxes to prompt the user for filenames */
  597. #if     WINDOW_MSWIN
  598. #define FILENAMEREPLY(p,b,nb)   filenamedlg(p,b,nb,TRUE)
  599. #else
  600. #define FILENAMEREPLY(p,b,nb)   mlreply(p,b,nb)
  601. #endif
  602.  
  603. /*
  604.  * There is a window structure allocated for every active display window. The
  605.  * windows are kept in a big list, in top to bottom screen order, with the
  606.  * listhead at "wheadp". Each window contains its own values of dot and mark.
  607.  * The flag field contains some bits that are set by commands to guide
  608.  * redisplay. Although this is a bit of a compromise in terms of decoupling,
  609.  * the full blown redisplay is just too expensive to run for every input
  610.  * character.
  611.  */
  612. typedef struct    WINDOW {
  613.     struct    WINDOW *w_wndp;     /* Next window            */
  614.     struct    BUFFER *w_bufp;     /* Buffer displayed in window    */
  615.     struct    LINE *w_linep;        /* Top line in the window    */
  616.     struct    LINE *w_dotp;        /* Line containing "."        */
  617.     short    w_doto;         /* Byte offset for "."        */
  618.     struct    LINE *w_markp[NMARKS];    /* Line containing "mark"    */
  619.     short    w_marko[NMARKS];    /* Byte offset for "mark"    */
  620.     char    w_toprow;        /* Origin 0 top row of window    */
  621.     char    w_ntrows;        /* # of rows of text in window    */
  622.     char    w_force;        /* If NZ, forcing row.        */
  623.     char    w_flag;         /* Flags.            */
  624. #if    COLOR
  625.     char    w_fcolor;        /* current forground color      */
  626.     char    w_bcolor;        /* current background color    */
  627. #endif
  628.     int    w_fcol;         /* first column displayed    */
  629. }    WINDOW;
  630.  
  631. #define WFFORCE 0x01            /* Window needs forced reframe    */
  632. #define WFMOVE    0x02            /* Movement from line to line    */
  633. #define WFEDIT    0x04            /* Editing within a line    */
  634. #define WFHARD    0x08            /* Better to a full display    */
  635. #define WFMODE    0x10            /* Update mode line.        */
  636. #define    WFCOLR    0x20            /* Needs a color change        */
  637.  
  638. /* This structure holds the information about each line appearing on the
  639.  * video display. The redisplay module uses an array of virtual display
  640.  * lines. On systems that do not have direct access to display memory,
  641.  * there is also an array of physical display lines used to minimize
  642.  * video updating. In most cases, these two arrays are unique. If
  643.  * WINDOW_MSWIN is 1, there is a pair of such arrays in each SCREEN
  644.  * structure.
  645.  */
  646.  
  647. typedef struct    VIDEO {
  648.     int    v_flag;         /* Flags */
  649. #if    COLOR
  650.     int    v_fcolor;        /* current forground color */
  651.     int    v_bcolor;        /* current background color */
  652.     int    v_rfcolor;        /* requested forground color */
  653.     int    v_rbcolor;        /* requested background color */
  654. #endif
  655. #if    INSDEL && MEMMAP == 0
  656.     int    v_rline;        /* requested screen line # */
  657. #endif
  658.     char    v_text[1];        /* Screen data. */
  659. }    VIDEO;
  660.  
  661. #define VFCHG    0x0001            /* Changed flag         */
  662. #define VFEXT    0x0002            /* extended (beyond column 80)    */
  663. #define VFREV    0x0004            /* reverse video status     */
  664. #define VFREQ    0x0008            /* reverse video request    */
  665. #define VFCOL    0x0010            /* color change requested    */
  666. #define VFNEW   0x8000                  /* contents not meaningful yet  */
  667.  
  668. /*
  669.  *    This structure holds the information about each separate "screen"
  670.  * within the current editing session.  On a character based system, these
  671.  * screens overlay each other, and can individually be brought to front.
  672.  * On a windowing system like MicroSoft Windows 3.0, OS/2, the Macintosh,
  673.  * Intuition, Sunview or X-windows, each screen is represented in an OS
  674.  * window.  The terminolgy is wrong in emacs.....
  675.  *
  676.  *    EMACS        The outside World
  677.  *    screen        window
  678.  *    window        pane
  679.  */
  680.  
  681. typedef struct SCREEN {
  682.     struct SCREEN *s_next_screen;    /* link to next screen in list */
  683.     WINDOW *s_first_window;        /* head of linked list of windows */
  684.     WINDOW *s_cur_window;        /* current window in this screen */
  685.     char *s_screen_name;        /* name of the current window */
  686.     short s_roworg;            /* row origin of stored screen */
  687.     short s_colorg;            /* column origin of stored screen */
  688.     short s_nrow;            /* row width of stored screen */
  689.     short s_ncol;            /* column origin of stored screen */
  690. #if WINDOW_MSWIN
  691.         VIDEO **s_virtual;              /* virtual screen contents */
  692.         VIDEO **s_physical;             /* physical screen contents */
  693.         int     s_drvhandle;            /* handle for the "term" driver */
  694. #endif
  695. } SCREEN;
  696.  
  697. /*
  698.  * Text is kept in buffers. A buffer header, described below, exists for every
  699.  * buffer in the system. The buffers are kept in a big list, so that commands
  700.  * that search for a buffer by name can find the buffer header. There is a
  701.  * safe store for the dot and mark in the header, but this is only valid if
  702.  * the buffer is not being displayed (that is, if "b_nwnd" is 0). The text for
  703.  * the buffer is kept in a circularly linked list of lines, with a pointer to
  704.  * the header line in "b_linep"    Buffers may be "Inactive" which means the files associated with them
  705.  * have not been read in yet. These get read in at "use buffer" time.
  706.  */
  707. typedef struct    BUFFER {
  708.     struct    BUFFER *b_bufp;     /* Link to next BUFFER        */
  709.     struct    LINE *b_dotp;        /* Link to "." LINE structure    */
  710.     short    b_doto;         /* Offset of "." in above LINE    */
  711.     struct    LINE *b_markp[NMARKS];    /* The same as the above two,    */
  712.     short    b_marko[NMARKS];    /* but for the "mark"        */
  713.     int    b_fcol;            /* first col to display        */
  714.     struct    LINE *b_linep;        /* Link to the header LINE    */
  715.     struct    LINE *b_topline;    /* Link to narrowed top text    */
  716.     struct    LINE *b_botline;    /* Link to narrowed bottom text    */
  717.     char    b_active;        /* window activated flag    */
  718.     char    b_nwnd;         /* Count of windows on buffer    */
  719.     char     b_exec;            /* how many active executions    */
  720.     char    b_flag;         /* Flags            */
  721.     int    b_mode;            /* editor mode of this buffer    */
  722.     char    b_fname[NFILEN];    /* File name            */
  723.     char    b_bname[NBUFN];     /* Buffer name            */
  724. #if    CRYPT
  725.     char   b_key[NPAT];           /* current encrypted key        */
  726. #endif
  727. }    BUFFER;
  728.  
  729. #define BFINVS    0x01            /* Internal invisable buffer    */
  730. #define BFCHG    0x02            /* Changed since last write    */
  731. #define    BFTRUNC    0x04            /* buffer was truncated when read */
  732. #define    BFNAROW    0x08            /* buffer has been narrowed    */
  733.  
  734. /*    mode flags    */
  735. #define    NUMMODES    10           /* # of defined modes           */
  736.  
  737. #define MDWRAP    0x0001            /* word wrap            */
  738. #define    MDCMOD    0x0002            /* C indentation and fence match*/
  739. #define    MDSPELL    0x0004            /* spell error parsing        */
  740. #define    MDEXACT    0x0008            /* Exact matching for searches    */
  741. #define    MDVIEW    0x0010            /* read-only buffer        */
  742. #define MDOVER    0x0020            /* overwrite mode        */
  743. #define MDMAGIC    0x0040            /* regular expresions in search */
  744. #define    MDCRYPT    0x0080            /* encrytion mode active    */
  745. #define    MDASAVE    0x0100            /* auto-save mode        */
  746. #define    MDREPL    0x0200            /* replace mode            */
  747.  
  748. /*
  749.  * The starting position of a region, and the size of the region in
  750.  * characters, is kept in a region structure.  Used by the region commands.
  751.  */
  752. typedef struct    {
  753.     struct    LINE *r_linep;        /* Origin LINE address.     */
  754.     short    r_offset;        /* Origin LINE offset.        */
  755.     long    r_size;         /* Length in characters.    */
  756. }    REGION;
  757.  
  758. /*
  759.  * All text is kept in circularly linked lists of "LINE" structures. These
  760.  * begin at the header line (which is the blank line beyond the end of the
  761.  * buffer). This line is pointed to by the "BUFFER". Each line contains a the
  762.  * number of bytes in the line (the "used" size), the size of the text array,
  763.  * and the text. The end of line is not stored as a byte; it's implied.
  764.  */
  765. typedef struct    LINE {
  766.     struct    LINE *l_fp;        /* Link to the next line    */
  767.     struct    LINE *l_bp;        /* Link to the previous line    */
  768.     short    l_size;         /* Allocated size        */
  769.     short    l_used;         /* Used size            */
  770.     char    l_text[1];        /* A bunch of characters.    */
  771. }    LINE;
  772.  
  773. #define lforw(lp)    ((lp)->l_fp)
  774. #define lback(lp)    ((lp)->l_bp)
  775. #define lgetc(lp, n)    ((lp)->l_text[(n)]&0xFF)
  776. #define lputc(lp, n, c) ((lp)->l_text[(n)]=(c))
  777. #define llength(lp)    ((lp)->l_used)
  778.  
  779. /*
  780.  * The editor communicates with the display using a high level interface. A
  781.  * "TERM" structure holds useful variables, and indirect pointers to routines
  782.  * that do useful operations. The low level get and put routines are here too.
  783.  * This lets a terminal, in addition to having non standard commands, have
  784.  * funny get and put character code too. The calls might get changed to
  785.  * "termp->t_field" style in the future, to make it possible to run more than
  786.  * one terminal type.
  787.  */
  788. typedef struct    {
  789.     short    t_mrow;          /* max number of rows allowable */
  790.     short    t_nrow;         /* current number of rows used    */
  791.     short    t_mcol;         /* max Number of columns.    */
  792.     short    t_ncol;         /* current Number of columns.    */
  793.     short    t_roworg;        /* origin row (normally zero)    */
  794.     short    t_colorg;        /* origin column (normally zero)*/
  795.     short    t_margin;        /* min margin for extended lines*/
  796.     short    t_scrsiz;        /* size of scroll region "    */
  797.     int    t_pause;        /* # times thru update to pause */
  798.     int (PASCAL NEAR *t_open)();    /* Open terminal at the start.    */
  799.     int (PASCAL NEAR *t_close)();    /* Close terminal at end.    */
  800.     int (PASCAL NEAR *t_kopen)();    /* Open keyboard        */
  801.     int (PASCAL NEAR *t_kclose)();    /* close keyboard        */
  802.     int (PASCAL NEAR *t_getchar)(); /* Get character from keyboard. */
  803.     int (PASCAL NEAR *t_putchar)(); /* Put character to display.    */
  804.     int (PASCAL NEAR *t_flush)();    /* Flush output buffers.    */
  805.     int (PASCAL NEAR *t_move)();    /* Move the cursor, origin 0.    */
  806.     int (PASCAL NEAR *t_eeol)();    /* Erase to end of line.    */
  807.     int (PASCAL NEAR *t_eeop)();    /* Erase to end of page.    */
  808.     int (PASCAL NEAR *t_clrdesk)();    /* Clear the page totally    */
  809.     int (PASCAL NEAR *t_beep)();    /* Beep.            */
  810.     int (PASCAL NEAR *t_rev)();    /* set reverse video state    */
  811.     int (PASCAL NEAR *t_rez)();    /* change screen resolution    */
  812. #if    COLOR
  813.     int (PASCAL NEAR *t_setfor)();     /* set forground color        */
  814.     int (PASCAL NEAR *t_setback)();    /* set background color        */
  815. #endif
  816. #if    INSDEL
  817.     int (PASCAL NEAR *t_insline)();    /* insert a screen line        */
  818.     int (PASCAL NEAR *t_delline)();    /* delete a screen line        */
  819. #endif
  820. #if     WINDOW_MSWIN
  821.         int (PASCAL NEAR *t_sleep)();   /* go to sleep for a while */
  822.         int (PASCAL NEAR *t_newscr)();  /* create new screen display */
  823.         int (PASCAL NEAR *t_delscr)();  /* destroy screen display */
  824.         int (PASCAL NEAR *t_selscr)();  /* select screen display */
  825.         int (PASCAL NEAR *t_sizscr)();  /* resize screen display */
  826.         int (PASCAL NEAR *t_topscr)();  /* bring screen to top */
  827. #endif
  828. }    TERM;
  829.  
  830. /*    TEMPORARY macros for terminal I/O  (to be placed in a machine
  831.                         dependant place later) */
  832.  
  833. #define TTopen        (*term.t_open)
  834. #define    TTclose        (*term.t_close)
  835. #define    TTkopen        (*term.t_kopen)
  836. #define    TTkclose    (*term.t_kclose)
  837. #define    TTgetc        (*term.t_getchar)
  838. #define    TTputc        (*term.t_putchar)
  839. #define    TTflush        (*term.t_flush)
  840. #define    TTmove        (*term.t_move)
  841. #define    TTeeol        (*term.t_eeol)
  842. #define    TTeeop        (*term.t_eeop)
  843. #define    TTclrdesk    (*term.t_clrdesk)
  844. #define    TTbeep        (*term.t_beep)
  845. #define    TTrev        (*term.t_rev)
  846. #define    TTrez        (*term.t_rez)
  847. #if    COLOR
  848. #define    TTforg        (*term.t_setfor)
  849. #define    TTbacg        (*term.t_setback)
  850. #endif
  851.  
  852. /*    Structure for the table of current key bindings     */
  853.  
  854. ETYPE EPOINTER {
  855.     int (PASCAL NEAR *fp)();    /* C routine to invoke */
  856.     BUFFER *buf;            /* buffer to execute */
  857. };
  858.  
  859. typedef struct    {
  860.     short k_code;         /* Key code            */
  861.     short k_type;        /* binding type (C function or EMACS buffer) */
  862.     ETYPE EPOINTER k_ptr;    /* ptr to thing to execute */
  863. }    KEYTAB;
  864.  
  865. /*    structure for the name binding table        */
  866.  
  867. typedef struct {
  868.     char *n_name;            /* name of function key */
  869.     int (PASCAL NEAR *n_func)();    /* function name is bound to */
  870. }    NBIND;
  871.  
  872. /*    The editor holds deleted text chunks in the KILL buffer. The
  873.     kill buffer is logically a stream of ascii characters, however
  874.     due to its unpredicatable size, it gets implemented as a linked
  875.     list of chunks. (The d_ prefix is for "deleted" text, as k_
  876.     was taken up by the keycode structure)
  877. */
  878.  
  879. typedef struct KILL {
  880.     struct KILL *d_next;   /* link to next chunk, NULL if last */
  881.     char d_chunk[KBLOCK];    /* deleted text */
  882. } KILL;
  883.  
  884. /*    When emacs' command interpetor needs to get a variable's name,
  885.     rather than it's value, it is passed back as a VDESC variable
  886.     description structure. The v_num field is a index into the
  887.     appropriate variable table.
  888. */
  889.  
  890. typedef struct VDESC {
  891.     int v_type;    /* type of variable */
  892.     int v_num;    /* ordinal pointer to variable in list */
  893. } VDESC;
  894.  
  895. /*    The !WHILE directive in the execution language needs to
  896.     stack references to pending whiles. These are stored linked
  897.     to each currently open procedure via a linked list of
  898.     the following structure
  899. */
  900.  
  901. typedef struct WHBLOCK {
  902.     LINE *w_begin;        /* ptr to !while statement */
  903.     LINE *w_end;        /* ptr to the !endwhile statement*/
  904.     int w_type;        /* block type */
  905.     struct WHBLOCK *w_next;    /* next while */
  906. } WHBLOCK;
  907.  
  908. #define BTWHILE     1
  909. #define    BTBREAK        2
  910.  
  911.  
  912. /* HICHAR - 1 is the largest character we will deal with.
  913.  * HIBYTE represents the number of bytes in the bitmap.
  914.  */
  915. #define HICHAR        256
  916. #if OS2
  917. #define    HIBYTE_        HICHAR >> 3
  918. #else
  919. #define    HIBYTE        HICHAR >> 3
  920. #endif
  921.  
  922. #if    MAGIC
  923. /*
  924.  * Defines for the metacharacters in the regular expression
  925.  * search routines.  MCNIL and LITCHAR are used in both search
  926.  * and replace metachar-arrays.
  927.  */
  928. #define MCNIL        0    /* Like the '\0' for strings.*/
  929. #define    LITCHAR        1    /* Literal character, or string.*/
  930. #define    ANY        2
  931. #define    CCL        3
  932. #define    NCCL        4
  933. #define    BOL        5
  934. #define    EOL        6
  935. #define    GRPBEG        0x0010    /* Toggle-able value for group begin.*/
  936. #define    GRPEND        0x0020    /* Toggle-able value for group end.*/
  937.  
  938. #define    DITTO        2    /* Replacement #define.*/
  939. #define GROUP        3    /* Replacement #define.*/
  940.  
  941. #define    CLOSURE        0x0100    /* An or-able value for a closure modifier.*/
  942. #define    CLOSURE_1    0x0200    /* An or-able value for a closure modifier.*/
  943. #define    ZEROONE        0x0400    /* An or-able value for a closure modifier.*/
  944.  
  945. #define ALLCLOS        (CLOSURE | CLOSURE_1 | ZEROONE)
  946. #define    MASKCLO        (~ALLCLOS)
  947.  
  948. #define MC_ANY        '.'    /* 'Any' character (except newline).*/
  949. #define    MC_CCL        '['    /* Character class.*/
  950. #define    MC_NCCL        '^'    /* Negate character class.*/
  951. #define    MC_RCCL        '-'    /* Range in character class.*/
  952. #define    MC_ECCL        ']'    /* End of character class.*/
  953. #define    MC_BOL        '^'    /* Beginning of line.*/
  954. #define    MC_EOL        '$'    /* End of line.*/
  955. #define    MC_CLOSURE    '*'    /* Closure - zero to many characters match.*/
  956. #define    MC_CLOSURE_1    '+'    /* Closure - one to many characters match.*/
  957. #define    MC_ZEROONE    '?'    /* Closure - zero to one characters match.*/
  958. #define    MC_DITTO    '&'    /* Use matched string in replacement.*/
  959. #define MC_GRPBEG    '('    /* Start of group (begun with a backslash).*/
  960. #define MC_GRPEND    ')'    /* End of group (begun with a backslash).*/
  961. #define    MC_ESC        '\\'    /* Escape - suppress meta-meaning.*/
  962.  
  963. #define MAXGROUPS    10        /* 1 + maximum # of r. e. groups. */
  964. #define BIT(n)        (1 << (n))    /* An integer with one bit set.*/
  965.  
  966. /* Typedefs that define the bitmap type for searching (BITMAP),
  967.  * the meta-character structure for MAGIC mode searching (MC),
  968.  * and the meta-character structure for MAGIC mode replacment (RMC).
  969.  */
  970. typedef char    *BITMAP;
  971.  
  972. typedef struct {
  973.     short int    mc_type;
  974.     union {
  975.         int    lchar;
  976.         int    group_no;
  977.         BITMAP    cclmap;
  978.     } u;
  979. } MC;
  980.  
  981. typedef struct {
  982.     short int      mc_type;
  983.     union {
  984.         int    group_no;
  985.         char    *rstr;
  986.     } u;
  987. } RMC;
  988. #endif
  989.  
  990. /*
  991.     This is the message which should be added to any "About MicroEMACS"
  992.     boxes on any of the machines with window managers.
  993.  
  994.  
  995.     ------------------------------------------
  996.     |                     |
  997.     |     MicroEMACS v3.xx         |
  998.     |        for the ............     |
  999.     |                     |
  1000.     |    Text Editor and Corrector         |
  1001.     |                     |
  1002.     |    written by Daniel M. Lawrence     |
  1003.     |    [based on code by Dave Conroy]     |
  1004.     |                     |
  1005.     |    Send inquiries and donations to:     |
  1006.     |    617 New York St             |
  1007.     |    Lafayette, IN 47901         |
  1008.     |                     |
  1009.     ------------------------------------------
  1010. */
  1011.